|
|
|
|
|
|
|
' create the objects
Set db = DBEngine.OpenDatabase(strDBName)
Set rs = db.OpenRecordset(strRSName, dbOpenDynaset)
'
' count the records in the collection
rs.MoveLast ' move to end of list to force a count
intRecs = rs.RecordCount ' get count
MsgBox strRSName & " :" & CStr(intRecs), vbInformation, "Total Records in
Set"
'
' create filtered collection
rs.Filter = strFilter
Set rs2 = rs.OpenRecordset
'
' count the records in the collection
rs2.MoveLast ' move to end of list to force a count
intRecs = rs2.RecordCount ' get count
MsgBox strFilter & " :" & CStr(intRecs), vbInformation, "Total Records in
Set"
'
' clone the recordset
Set rs3 = rs.Clone ' clone it
rs3.MoveLast ' move to end
intRecs = rs3.RecordCount ' get count
MsgBox "Cloned Recordset: " & CStr(intRecs), vbInformation, "Total Records
in Set"
'
End Sub |
|
|
|
|
|
|
|
|
Notice that all you have to do to clone a Recordset is to use the Clone method to load a new Recordset object variable. When you run the program this time, you see that the Recordset created using the Clone method contains the same number of records as its parent. |
|
|
|
|
|
|
|
|
Dynasets Can Use Bookmarks, Filters, and Sorts |
|
|
|
|
|
|
|
|
Dynaset-type Recordsets can use the Bookmark, Filter, and Sort properties to reorder data for display (Sort) or create a subset of the Recordset (Filter). Using the Visual Basic Find method on a Recordset forces Visual Basic to start at the first record in the collection and read each one until a match is found. Once the selected record is found, your user may want to return to the record that was displayed before the search began. That's what Visual Basic Bookmarks do. They remember where you were. |
|
|
|
|
|
|
|
|
When you search for a record in the dataset using one of the Find methods, you should set Bookmarks before your search to remember where you started. This is especially handy if your Find criteria results in a null record. When a FindFirst method fails to locate the desired record, the record pointer is set to the first record in the collection. If you have saved the bookmark before starting the search, you can reset the Visual Basic Bookmark and return the user to the place from which the search started. |
|
|
|
|
|